<?php

namespace app\admin\model\store;

use think\Model;


class Order extends Model
{

    

    

    // 表名
    protected $name = 'store_order';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'zstart_time_text',
        'zend_time_text',
        'estimated_time_text',
        'delivery_time_text',
        'return_time_text',
        'is_overtime_text',
        'order_acceptance_time_text',
        'appeal_time_text',
        'pickup_time_text',
        'deliveryd_time_text',
        'service_completion_time_text'
    ];
    

    



    public function getZstartTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['zstart_time']) ? $data['zstart_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getZendTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['zend_time']) ? $data['zend_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getEstimatedTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['estimated_time']) ? $data['estimated_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getDeliveryTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['delivery_time']) ? $data['delivery_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getReturnTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['return_time']) ? $data['return_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getIsOvertimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_overtime']) ? $data['is_overtime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getOrderAcceptanceTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['order_acceptance_time']) ? $data['order_acceptance_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getAppealTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['appeal_time']) ? $data['appeal_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getPickupTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['pickup_time']) ? $data['pickup_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getDeliverydTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['deliveryd_time']) ? $data['deliveryd_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getServiceCompletionTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['service_completion_time']) ? $data['service_completion_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    protected function setZstartTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setZendTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setEstimatedTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setDeliveryTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setReturnTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setIsOvertimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setOrderAcceptanceTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setAppealTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setPickupTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setDeliverydTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setServiceCompletionTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
